<template>
  <view class="agreement-container">
    <!-- 协议内容 (富文本) -->
    <rich-text class="agreement-content" :nodes="agreementContent"></rich-text>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { userProxy, privacyProxy } from './proxy'

// 协议标题
const agreementTitle = ref('')

// 协议内容 (富文本格式)
const agreementContent = ref('')

const setNavTitle = (type) => {
  uni.setNavigationBarTitle({
    title: type === 'user' ? '用户服务协议' : '隐私政策'
  })
}

onLoad((options) => {
  // 根据传入参数确定是用户协议还是隐私政策
  setNavTitle(options.type)
  if (options.type === 'user') {
    agreementTitle.value = '用户服务协议'
    agreementContent.value = userProxy
  } else {
    agreementTitle.value = '隐私政策'
    agreementContent.value = privacyProxy
  }
})
</script>

<style lang="scss" scoped>
.agreement-container {
  padding: 20rpx;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #ffffff;
}


.agreement-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 40rpx;
}
</style>